package net.metashare.grah.operation

import net.metashare.grah.Graph
import net.metashare.grah.ResultGraph
import net.metashare.grah.pogo.SimplePogoGraph
import net.metashare.grah.logic.Predicate
import net.metashare.grah.Edge
import net.metashare.grah.meta.MetaContext

/**
 * Grah is a notion produced by metashare.net
 * User: dsherema
 * Date: May 1, 2010
 * Time: 5:26:12 PM
 *
 */
class Combine extends MultiOperation {

  def ResultGraph apply(Graph graph1, Graph graph2) {
    return apply([graph1, graph2])
  }

  def ResultGraph apply(Graph graph) {
    return apply(graph)
  }

  def ResultGraph apply(List<Graph> graphs) {
    ResultGraph result = new ResultGraph()
    result.graphs = graphs
    result.supergraph = new SimplePogoGraph()
    result.operation = this

    graphs.each() { graph ->
      result.selection.addNodes(graph.nodes())
      result.selection.addNodes(graph.edges())
    }
    return result
  }


  def List nodes(Predicate p) {
    return output.nodes(p)  //To change body of implemented methods use File | Settings | File Templates.
  }

  def List<Edge> edges(Predicate p) {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
  }

  def MetaContext context() {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
  }
}
